using System;
using System.Data;
using System.Collections.Generic;
namespace Sync.DAO{
	/********************************BEGIN SyncTablesDAOBase****************************************/
	///<summary>
	/// <para>Author: Auto generated class by CSharp Code Generator v2.0</para>
	/// <para>Date:21/03/2011 24:09:58</para>
	/// <para>Class Name: SyncTablesDAOBase</para>
	/// <para>Description: Class access to table SyncTables in database. Coder should'nt code here.</para>
	///</summary>

	
	public abstract class SyncTablesDAOBase : ADOBase.DAOBase<SyncTablesEntity>{


		#region Select functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: CreateSelectOneCommand</para>
		/// <para>Input: SyncTable_ID</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectOneCommand(int SyncTable_ID){
			string strSQL="SELECT  [SyncTable_ID],[SyncTableName] FROM [SyncTables]  WHERE [SyncTables].[SyncTable_ID]=@SyncTable_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@SyncTable_ID",SyncTable_ID);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: SelectOne</para>
		/// <para>Input: SyncTable_ID</para>
		/// <para>Output: SyncTablesEntity</para>
		///</summary>
		public SyncTablesEntity SelectOne(int SyncTable_ID){
			IDbCommand cmd=this.CreateSelectOneCommand(SyncTable_ID);
			return this.Select(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: CreateSelectAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllCommand(){
			string strSQL="SELECT  [SyncTable_ID],[SyncTableName] FROM [SyncTables] ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: CreateSelectAllByKeyCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyCommand(string ColumnName,object Value){
			string strSQL="SELECT  [SyncTable_ID],[SyncTableName] FROM [SyncTables]  WHERE [SyncTables].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of SyncTablesEntity</para>
		///</summary>
		public List<SyncTablesEntity> SelectAll(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: SelectAllDS</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDS(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectDS(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: CreateSelectAllFilterCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllFilterCommand(string strFilter){
			string strSQL="SELECT  [SyncTable_ID],[SyncTableName] FROM [SyncTables]  WHERE "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: CreateSelectAllByKeyFilterCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyFilterCommand(string strFilter,string ColumnName,object Value){
			string strSQL="SELECT  [SyncTable_ID],[SyncTableName] FROM [SyncTables]  WHERE [SyncTables].["+ColumnName+"]=@ColumnName AND "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of SyncTablesEntity</para>
		///</summary>
		public List<SyncTablesEntity> SelectAllFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: SelectAllDSFilter</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDSFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectDS(cmd);
		}
		#endregion

		#region Insert functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: CreateInsertCommand</para>
		/// <para>Input: SyncTablesEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateInsertCommand(SyncTablesEntity o){
			string strSQL="INSERT INTO [SyncTables]([SyncTable_ID],[SyncTableName]) VALUES  (@SyncTable_ID,@SyncTableName)";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullSyncTable_ID)
				this.CreateCommandParameter(cmd,"@SyncTable_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SyncTable_ID",o.SyncTable_ID);

			if(o.IsNullSyncTableName)
				this.CreateCommandParameter(cmd,"@SyncTableName",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SyncTableName",o.SyncTableName);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: Save</para>
		/// <para>Input: SyncTablesEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Save(SyncTablesEntity o){
			IDbCommand cmd=this.CreateInsertCommand(o);
			bool result=false;
			result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: SaveList</para>
		/// <para>Input: List of SyncTablesEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void SaveList(List<SyncTablesEntity>list){
			foreach(SyncTablesEntity o in list){
				try{
					this.Save(o);
				}
				catch{
				}
			}
		}
		#endregion

		#region Update functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: CreateUpdateCommand</para>
		/// <para>Input: SyncTablesEntity</para>
		/// <para>Output: </para>
		///</summary>
		protected IDbCommand CreateUpdateCommand(SyncTablesEntity o){
			string strSQL="UPDATE  [SyncTables] SET [SyncTables].[SyncTable_ID]=@SyncTable_ID,[SyncTables].[SyncTableName]=@SyncTableName WHERE [SyncTables].[SyncTable_ID]=@OldSyncTable_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullSyncTable_ID)
				this.CreateCommandParameter(cmd,"@SyncTable_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SyncTable_ID",o.SyncTable_ID);

			if(o.IsNullSyncTableName)
				this.CreateCommandParameter(cmd,"@SyncTableName",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SyncTableName",o.SyncTableName);

			if(o.IsNullOldSyncTable_ID)
				this.CreateCommandParameter(cmd,"@OldSyncTable_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@OldSyncTable_ID",o.OldSyncTable_ID);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: CreateUpdateFieldCommand</para>
		/// <para>Input: ColumnName,ColumnValue,SyncTable_ID</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateUpdateFieldCommand(string ColumnName,object Value,int SyncTable_ID){
			string strSQL="UPDATE  [SyncTables] SET [SyncTables].["+ColumnName+"]=@ColumnName WHERE [SyncTables].[SyncTable_ID]=@SyncTable_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@SyncTable_ID",SyncTable_ID);



			this.CreateCommandParameter(cmd,"@ColumnName",Value);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: Update</para>
		/// <para>Input: SyncTablesEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Update(SyncTablesEntity o){
			IDbCommand cmd=this.CreateUpdateCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: UpdateList</para>
		/// <para>Input: List of SyncTablesEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void UpdateList(List<SyncTablesEntity>list){
			foreach(SyncTablesEntity o in list){
				try{
					this.Update(o);
				}
				catch{
				}
			}
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: UpdateSyncTable_ID</para>
		/// <para>Input: NewSyncTable_ID,SyncTable_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateSyncTable_ID(int NewSyncTable_ID,int SyncTable_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("SyncTable_ID",NewSyncTable_ID,SyncTable_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: UpdateSyncTableName</para>
		/// <para>Input: NewSyncTableName,SyncTable_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateSyncTableName(string NewSyncTableName,int SyncTable_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("SyncTableName",NewSyncTableName,SyncTable_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Delete functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: DeleteAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteAllCommand(){
			string strSQL="DELETE   FROM [SyncTables]  ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: DeleteCommand</para>
		/// <para>Input: SyncTablesEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteCommand(SyncTablesEntity o){
			string strSQL="DELETE   FROM [SyncTables]   WHERE [SyncTables].[SyncTable_ID]=@SyncTable_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullSyncTable_ID)
				this.CreateCommandParameter(cmd,"@SyncTable_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SyncTable_ID",o.SyncTable_ID);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: DeleteAll</para>
		/// <para>Input: </para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteAll(){
			IDbCommand cmd=this.CreateDeleteAllCommand();
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: CreateDeleteByPrimaryKeyCommand</para>
		/// <para>Input: SyncTable_ID</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByPrimaryKeyCommand(int SyncTable_ID){
			string strSQL="DELETE   FROM [SyncTables]   WHERE [SyncTables].[SyncTable_ID]=@SyncTable_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@SyncTable_ID",SyncTable_ID);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: CreateDeleteByKeyCommand</para>
		/// <para>Input: ColumnName , ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByKeyCommand(string ColumnName,object Value){
			string strSQL="DELETE   FROM [SyncTables]   WHERE [SyncTables].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: Delete</para>
		/// <para>Input: SyncTablesEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Delete(SyncTablesEntity o){
			IDbCommand cmd=this.CreateDeleteCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: DeleteByID</para>
		/// <para>Input: SyncTable_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteByID(int SyncTable_ID){
			IDbCommand cmd=this.CreateDeleteByPrimaryKeyCommand(SyncTable_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Select,delete by SyncTable_ID functions
		#endregion

		#region MapObject functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:21/03/2011 24:09:58</para>
		/// <para>Name: MapObject</para>
		/// <para>Input: IDataReader</para>
		/// <para>Output: SyncTablesEntity</para>
		///</summary>
		protected override SyncTablesEntity MapObject(IDataReader r){
			SyncTablesEntity entity = new SyncTablesEntity();
			try{
				if(r.FieldCount>0){
					try
					{
						int ordinal = r.GetOrdinal("SyncTable_ID");
						if (!r.IsDBNull(ordinal)) entity.SyncTable_ID = ((int)(r.GetValue(ordinal)));
						entity.OldSyncTable_ID=entity.SyncTable_ID;
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("SyncTableName");
						if (!r.IsDBNull(ordinal)) entity.SyncTableName = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					return entity;
				}
			}catch{}
			return null;
		}
		#endregion
	}
	/*****************************************************************************************************/
	/**********************************END SyncTablesDAOBase*****************************************/
	/*****************************************************************************************************/
}

